﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Helpers;
using dotnethost.Watermark.Models;
namespace dotnethost.Watermark
{
    public class WatermarkCreator
    {
        public string MarkedImagePath { get; set; }
        private WebImage _originalImage;
        private HttpContextBase _context;
        private WatermarkFont _font;
        public WatermarkCreator(WebImage image, HttpContextBase context,WatermarkFont font)
        {
            _originalImage = image;
            _context=context;
            _font = font;
        }

        public void AddWaterMark(string waterMarkText)
        {
            string imageFileName =Guid.NewGuid()+"_"+_originalImage.FileName;
            _originalImage.AddTextWatermark(waterMarkText,_font.FontColor,_font.FontSize,_font.FontStyle,_font.FontFamily,
                _font.HorizontalAlign,_font.VerticalAlign,_font.Opacity,_font.Padding);
            _originalImage.Save(_context.Server.MapPath(@"/Content/images/temp/"+imageFileName));
            MarkedImagePath = "/Content/images/temp/" + imageFileName;
        }
    }
}